package com.example.mobile2121606109ycg0407;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivityTip6 extends AppCompatActivity {

    private EditText edtTxtMain6Num;
    private TextView tvMain6Result;
    private Button btnMain6Result;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_tip6);
        initView();

        btnMain6Result.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //获取输入的成绩
                int score = Integer.parseInt(edtTxtMain6Num.getText().toString());
                //成绩等级的判断并输出结果
                if (score >= 90 ) {
                    tvMain6Result.setText("A");
                }else if (score >= 80){
                    tvMain6Result.setText("B");
                }
                else if (score >= 70){
                    tvMain6Result.setText("c");
                }
                else if (score >= 60){
                    tvMain6Result.setText("D");
                }else {
                    tvMain6Result.setText("E");
                }
            }
        });
    }

    private void initView() {
        edtTxtMain6Num = (EditText) findViewById(R.id.edtTxtMain6_Num);
        tvMain6Result = (TextView) findViewById(R.id.tvMain6_Result);
        btnMain6Result = (Button) findViewById(R.id.btnMain6_Result);
    }
}